package adminRepository

import (
	adminModel "gin_http/internal/model/admin"
	commonError "gin_http/utils/common/error"
	commonRepository "gin_http/utils/common/repository"
)

type UserRepository struct {
	*commonRepository.BaseRepository[adminModel.User]
}

// NewUserRepository 构造函数，注入 BaseRepository[User]
func NewUserRepository(base *commonRepository.BaseRepository[adminModel.User]) *UserRepository {
	return &UserRepository{
		BaseRepository: base,
	}
}

func (u *UserRepository) GetByUserName(userName string) (*adminModel.User, *commonError.Error) {
	return u.FirstBy(map[string]interface{}{"username": userName})
}
func (u *UserRepository) GetByPhone(phone string) (*adminModel.User, *commonError.Error) {
	return u.FirstBy(map[string]interface{}{"phone": phone})
}
